home *** CD-ROM | disk | FTP | other *** search
- Path: news.informatik.uni-kiel.de!ma
- From: ma@informatik.uni-kiel.de (Martin Ameskamp)
- Newsgroups: comp.lang.c++
- Subject: Re: Determining Array size
- Date: 10 Apr 1996 15:44:02 GMT
- Organization: Dept. of Computer Science, University of Kiel, FRG
- Message-ID: <4kgl02$gnn@gutemine.informatik.uni-kiel.de>
- References: <316a9cef.44425478@news.synapse.net>
- NNTP-Posting-Host: rigel.informatik.uni-kiel.de
-
- In <316a9cef.44425478@news.synapse.net> phill@synapse.net (Phil Lachance) writes:
-
- >I would like to send an array to a function having to send the array
- >size, is there any way to determine the size of an array?
-
- If we're talking about low-level, C-type arrays - no.
- The only way to get information about the array size is to call
- sizeof on the actual array variable (_NOT_ on a pointer that
- points to the first element of the array).
-
- A function that is passed an array as a parameter doesn't know
- the size (of course, you can explicitly pass the size in a separate
- parameter or use a special element - like 0 in C strings - to
- denote the array end or ...)
-
- Since this is c.l.c++, your best bet is probably to use one of the
- many array classes floating around. Most of these provide a method
- to find out the size of the array.
-
- Martin
-